home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / vbcc-68k-src / machines / amiga68k / libsrc / stdio / _putbuf.c < prev    next >
C/C++ Source or Header  |  1999-01-01  |  782b  |  30 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. #include <proto/dos.h>
  5.  
  6. /*  schreibt Daten aus Buffer   */
  7. /*  fuegt c als neues Zeichen ein, falls c!=EOF */
  8. int _putbuf(int c,FILE *f)
  9. {
  10.     _chkabort();
  11.     if(!f) return(EOF);
  12.     if((f->flags&(_WRITEABLE|_READ|_EOF|_ERR))!=_WRITEABLE) return(EOF);
  13.     if(!f->bufsize){if(f->flags&_UNBUF) f->bufsize=1; else f->bufsize=BUFSIZ;}
  14.     if(!f->base){
  15.         if(!(f->base=(char *)malloc(f->bufsize+1)+1))
  16.             return(EOF);
  17.     }else{
  18.         int len=f->pointer-f->base;
  19.         if(Write((BPTR)f->filehandle,f->base,len)!=len){
  20.             f->flags|=_ERR;
  21.             return(EOF);
  22.         }
  23.     }
  24.     f->flags|=_WRITE;
  25.     *f->base=c;
  26.     f->pointer=f->base+1;
  27.     f->count=f->bufsize-1;
  28.     return(0);  /*  hier noch ueberlegen    */
  29. }
  30.